package cn.stronglink.asset.module.dam.utils.dataJsonUtils.realtime.send;

import com.alibaba.fastjson.JSON;

import cn.stronglink.asset.module.dam.entity.message.MsgRealTimeDatas;
import cn.stronglink.asset.module.dam.entity.message.MsgScreenCommand;
import cn.stronglink.asset.module.dam.entity.message.secondMsg.AwsPostdataCommand;

public class SendUtil {
	private static final String topic = "serviceToDam";
	private static MsgScreenCommand msg=null;
	
	static {
		msg = new MsgScreenCommand();// 大的消息对象
		msg.setActioncode("screenCommand");
		msg.setDevType("damDc");
		msg.setAwsPostdata(new AwsPostdataCommand());// 小的消息对象
		AwsPostdataCommand postData=new AwsPostdataCommand();
		msg.setAwsPostdata(postData);
	}

	public static void sendRealTimeDatas(MsgRealTimeDatas realDatas, String command){
	
		// 封装返回的Json数据
		msg.setTimestamp(realDatas.getTimestamp());
		AwsPostdataCommand postCmd=msg.getAwsPostdata();
		postCmd.setCommand(command);
		postCmd.setRackConverCode(realDatas.getAwsPostdata().getRackConverCode());
		
		//发送消息
		MsgSendUtil.sendMsg(topic, JSON.toJSONString(msg));
	}

}
